<template>
  <div class="app-container">
    <!--工具栏-->
    <div class="head-container">
      <div>
        <!-- 搜索 -->

        <el-input v-model="query.xm" clearable size="small" placeholder="姓名1" style="width: 170px;" class="filter-item" @keyup.enter.native="crud.toQuery" />
        <el-input v-model="query.sfz" clearable size="small" placeholder="身份证" style="width: 170px;" class="filter-item" @keyup.enter.native="crud.toQuery" />
        <el-select v-model="query.bisZhsqCblx" clearable size="small" placeholder="参保类型" class="filter-item" style="width: 120px">
          <el-option
            v-for="item in cblxTypeOptions"
            :key="item.key"
            :label="item.display_name"
            :value="item.key"
          />
        </el-select>
        <el-select v-model="query.sndj" clearable size="small" placeholder="失能登记" class="filter-item" style="width: 120px">
          <el-option
            v-for="item in sndjTypeOptions"
            :key="item.key"
            :label="item.display_name"
            :value="item.key"
          />
        </el-select>
        <el-select v-model="query.tcq" clearable size="small" placeholder="医保所属区县" class="filter-item" style="width: 130px">
          <el-option
            v-for="item in dict.ccstcqh"
            :key="item.id"
            :label="item.label"
            :value="item.value"
          />
        </el-select>
        <rrOperation :crud="crud" />
      </div>
      <!--表单组件-->
      <el-dialog :close-on-click-modal="false" :before-close="crud.cancelCU" :visible.sync="crud.status.cu > 0" :title="crud.status.title" width="660px">
        <el-form ref="form" :inline="true" :model="form" :rules="rules" size="small" label-width="110px">
          <el-form-item label="姓名" prop="bisZhsqSnryXm">
            <el-input v-model="form.bisZhsqSnryXm" disabled style="width: 170px;" />
          </el-form-item>
          <el-form-item label="身份证" prop="bisZhsqSnrySfz">
            <el-input v-model="form.bisZhsqSnrySfz" disabled style="width: 170px;" />
          </el-form-item>
          <el-form-item label="性别" prop="bisZhsqSnryXb">
            <el-input v-model="form.bisZhsqSnryXb" disabled style="width: 170px;" />
          </el-form-item>
          <el-form-item label="年龄" prop="bisZhsqNl">
            <el-input v-model="form.bisZhsqNl" disabled style="width: 170px;" />
          </el-form-item>
          <el-form-item label="医保卡号" prop="bisZhsqYbkh">
            <el-input v-model="form.bisZhsqYbkh" disabled style="width: 170px;" />
          </el-form-item>
          <el-form-item label="参保状态" prop="bisZhsqCbzt">
            <el-input v-model="form.bisZhsqCbzt" disabled style="width: 170px;" />
          </el-form-item>
          <el-form-item label="参保类型" prop="bisZhsqCblx">
            <el-input v-model="form.bisZhsqCblx" disabled style="width: 170px;" />
          </el-form-item>
          <el-form-item label="医保所属区县" prop="bisZhsqSnryYbssqx">
            <el-select v-model="form.bisZhsqSnryYbssqx" filterable placeholder="请选择" disabled style="width: 170px;">
              <el-option
                v-for="item in dict.ccstcqh"
                :key="item.id"
                :label="item.label"
                :value="item.value"
              />
            </el-select>
          </el-form-item>
          <el-form-item label="联系电话" prop="bisZhsqLxdh">
            <el-input v-model="form.bisZhsqLxdh" style="width: 170px;" />
          </el-form-item>
          <el-form-item label="地址" prop="bisZhsqHldz">
            <el-input v-model="form.bisZhsqHldz" style="width: 170px;" />
          </el-form-item>
          <el-form-item label="监护人姓名" prop="bisZhsqJhrxm">
            <el-input v-model="form.bisZhsqJhrxm" style="width: 170px;" />
          </el-form-item>
          <el-form-item label="监护人电话" prop="bisZhsqJhrdh">
            <el-input v-model="form.bisZhsqJhrdh" style="width: 170px;" />
          </el-form-item>
          <el-form-item label="关系" prop="bisZhsqGx">
            <el-select v-model="form.bisZhsqGx" filterable placeholder="请选择" style="width: 170px;">
              <el-option
                v-for="item in dict.yjsgx"
                :key="item.id"
                :label="item.label"
                :value="item.value"
              />
            </el-select>
          </el-form-item>
          <el-form-item v-if="!sbIsExist" label="ADL量表评分" prop="bisZhsqAdl">
            <el-input v-model="form.bisZhsqAdl" readonly style="width: 170px;" />
          </el-form-item>
          <el-form-item label="申请原因" prop="bisZhsqSqyy">
            <el-input v-model="form.bisZhsqSqyy" :rows="3" type="textarea" style="width: 470px;" />
          </el-form-item>
          <el-upload
            v-if="!sbIsExist"
            ref="upload_adl"
            disabled="true"
            :auto-upload="true"
            :on-preview="handlePreview"
            :before-upload="beforeVideoUpload"
            :before-remove="beforeRemove"
            :on-remove="handleRemove"
            :on-success="handleVideoSuccess"
            :on-error="handleError"
            :data="fjlb_adl"
            :headers="headers"
            :file-list="file_list_adl"
            :action="minioMpUploadVideoApi"
          />
        </el-form>
        <div slot="footer" class="dialog-footer">
          <el-button @click="crud.cancelCU">关 闭</el-button>
          <el-button type="info" @click="zhHistoryQuery()">查看意见</el-button>
        </div>
      </el-dialog>

      <!--高龄延期表单-->
      <el-dialog :visible.sync="glDelayDialog" title="高龄延期" width="660px">
        <el-form ref="form" :inline="true" :model="form" :rules="rules" size="small" label-width="110px">
          <el-form-item label="姓名" prop="bisZhsqSnryXm">
            <el-input v-model="form.bisZhsqSnryXm" disabled style="width: 170px;" />
          </el-form-item>
          <el-form-item label="身份证" prop="bisZhsqSnrySfz">
            <el-input v-model="form.bisZhsqSnrySfz" disabled style="width: 170px;" />
          </el-form-item>
          <el-form-item label="性别" prop="bisZhsqSnryXb">
            <el-input v-model="form.bisZhsqSnryXb" disabled style="width: 170px;" />
          </el-form-item>
          <el-form-item label="年龄" prop="tempNl">
            <el-input v-model="form.tempNl" disabled style="width: 170px;" />
          </el-form-item>
          <el-form-item label="医保卡号" prop="bisZhsqYbkh">
            <el-input v-model="form.bisZhsqYbkh" disabled style="width: 170px;" />
          </el-form-item>
          <el-form-item label="参保状态" prop="bisZhsqCbzt">
            <el-input v-model="form.bisZhsqCbzt" disabled style="width: 170px;" />
          </el-form-item>
          <el-form-item label="参保类型" prop="bisZhsqCblx">
            <el-input v-model="form.bisZhsqCblx" disabled style="width: 170px;" />
          </el-form-item>
          <el-form-item label="医保所属区县" prop="bisZhsqSnryYbssqx">
            <el-select v-model="form.bisZhsqSnryYbssqx" filterable placeholder="请选择" disabled style="width: 170px;">
              <el-option
                v-for="item in dict.ccstcqh"
                :key="item.id"
                :label="item.label"
                :value="item.value"
              />
            </el-select>
          </el-form-item>
          <el-form-item label="行政区划" prop="bisZhsqHldzSsqx">
            <el-select v-model="form.bisZhsqHldzSsqx" placeholder="请选择" style="width: 170px;">
              <el-option
                v-for="item in districts"
                :key="item.value"
                :label="item.label"
                :value="item.value"
              />
            </el-select>
          </el-form-item>
          <el-form-item label="地址" prop="bisZhsqHldz">
            <el-input v-model="form.bisZhsqHldz" style="width: 170px;" />
          </el-form-item>
          <el-form-item label="联系电话" prop="bisZhsqLxdh">
            <el-input v-model="form.bisZhsqLxdh" style="width: 170px;" />
          </el-form-item>
          <el-form-item label="监护人姓名" prop="bisZhsqJhrxm">
            <el-input v-model="form.bisZhsqJhrxm" style="width: 170px;" />
          </el-form-item>
          <el-form-item label="监护人电话" prop="bisZhsqJhrdh">
            <el-input v-model="form.bisZhsqJhrdh" style="width: 170px;" />
          </el-form-item>
          <el-form-item label="关系" prop="bisZhsqGx">
            <el-select v-model="form.bisZhsqGx" filterable placeholder="请选择" style="width: 170px;">
              <el-option
                v-for="item in dict.yjsgx"
                :key="item.id"
                :label="item.label"
                :value="item.value"
              />
            </el-select>
          </el-form-item>
          <el-form-item label="失能等级" prop="tempSndj">
            <el-select v-model="form.tempSndj" clearable size="small" placeholder="请选择" style="width: 170px;">
              <el-option
                v-for="item in gldjTypeOptions"
                :key="item.key"
                :label="item.display_name"
                :value="item.key"
              />
            </el-select>
          </el-form-item>
          <el-form-item label="申请原因" prop="bisZhsqSqyy">
            <el-input v-model="form.bisZhsqSqyy" :rows="3" type="textarea" style="width: 470px;" />
          </el-form-item>
          <el-upload
            ref="upload_sfz"
            :data="fjlb_sfz"
            :headers="headers"
            :action="minnioUploadHomeImage"
            :before-upload="beforeUpload"
            :before-remove="beforeRemove"
            :on-remove="handleRemove"
            :on-success="handleSfzSuccess"
            :on-progress="handleProgress"
            :on-error="handleError"
            :file-list="file_list_sfz"
            list-type="picture"
          >
            <el-button size="small" type="primary">上传身份证（正反面）</el-button>
            <div slot="tip" class="el-upload__tip">只能上传jpg/png文件，且不超过5MB</div>
          </el-upload>
          <el-upload
            ref="upload_sfz"
            :data="fjlb_shbzk"
            :headers="headers"
            :action="minnioUploadHomeImage"
            :before-upload="beforeUpload"
            :before-remove="beforeRemove"
            :on-remove="handleRemove"
            :on-success="handleYbkSuccess"
            :on-progress="handleProgress"
            :on-error="handleError"
            :file-list="file_list_shbzk"
            list-type="picture"
          >
            <el-button size="small" type="primary">上传社会保障卡（正反面）</el-button>
            <div slot="tip" class="el-upload__tip">只能上传jpg/png文件，且不超过5MB</div>
          </el-upload>
        </el-form>
        <div slot="footer" class="dialog-footer">
          <el-button @click="glDelayDialog = false">取消</el-button>
          <el-button type="primary" @click="doSave('00')">保存</el-button>
          <el-button type="success" @click="doSubmit('54')">提交</el-button>
        </div>
      </el-dialog>

      <!--高龄延期表单-->
      <el-dialog :visible.sync="snDelayDialog" title="高龄延期" width="660px">
        <el-form ref="form" :inline="true" :model="form" :rules="rules" size="small" label-width="110px">
          <el-form-item label="姓名" prop="bisZhsqSnryXm">
            <el-input v-model="form.bisZhsqSnryXm" disabled style="width: 170px;">
              <el-button slot="append" icon="el-icon-search" title="查找患者信息" @click="getSnry" />
            </el-input>
          </el-form-item>
          <el-form-item label="身份证" prop="bisZhsqSnrySfz">
            <el-input v-model="form.bisZhsqSnrySfz" disabled style="width: 170px;" />
          </el-form-item>
          <el-form-item label="性别" prop="bisZhsqSnryXb">
            <el-input v-model="form.bisZhsqSnryXb" disabled style="width: 170px;" />
          </el-form-item>
          <el-form-item label="年龄" prop="tempNl">
            <el-input v-model="form.tempNl" disabled style="width: 170px;" />
          </el-form-item>
          <el-form-item label="医保卡号" prop="bisZhsqYbkh">
            <el-input v-model="form.bisZhsqYbkh" disabled style="width: 170px;" />
          </el-form-item>
          <el-form-item label="参保状态" prop="bisZhsqCbzt">
            <el-input v-model="form.bisZhsqCbzt" disabled style="width: 170px;" />
          </el-form-item>
          <el-form-item label="参保类型" prop="bisZhsqCblx">
            <el-input v-model="form.bisZhsqCblx" disabled style="width: 170px;" />
          </el-form-item>
          <el-form-item label="医保所属区县" prop="bisZhsqSnryYbssqx">
            <el-select v-model="form.bisZhsqSnryYbssqx" filterable placeholder="请选择" disabled style="width: 170px;">
              <el-option
                v-for="item in dict.ccstcqh"
                :key="item.id"
                :label="item.label"
                :value="item.value"
              />
            </el-select>
          </el-form-item>
          <el-form-item label="行政区划" prop="bisZhsqHldzSsqx">
            <el-select v-model="form.bisZhsqHldzSsqx" placeholder="请选择" style="width: 170px;">
              <el-option
                v-for="item in districts"
                :key="item.value"
                :label="item.label"
                :value="item.value"
              />
            </el-select>
          </el-form-item>
          <el-form-item label="地址" prop="bisZhsqHldz">
            <el-input v-model="form.bisZhsqHldz" style="width: 170px;" />
          </el-form-item>
          <el-form-item label="联系电话" prop="bisZhsqLxdh">
            <el-input v-model="form.bisZhsqLxdh" style="width: 170px;" />
          </el-form-item>
          <el-form-item label="监护人姓名" prop="bisZhsqJhrxm">
            <el-input v-model="form.bisZhsqJhrxm" style="width: 170px;" />
          </el-form-item>
          <el-form-item label="监护人电话" prop="bisZhsqJhrdh">
            <el-input v-model="form.bisZhsqJhrdh" style="width: 170px;" />
          </el-form-item>
          <el-form-item label="关系" prop="bisZhsqGx">
            <el-select v-model="form.bisZhsqGx" filterable placeholder="请选择" style="width: 170px;">
              <el-option
                v-for="item in dict.yjsgx"
                :key="item.id"
                :label="item.label"
                :value="item.value"
              />
            </el-select>
          </el-form-item>
          <el-form-item label="ADL量表评分" prop="tempAdlFs">
            <el-input v-model="form.tempAdlFs" readonly style="width: 170px;">
              <el-button slot="append" icon="el-icon-document" title="测量ADL量表" @click="getAdl" />
            </el-input>
          </el-form-item>
          <el-form-item label="失能等级" prop="tempSndj">
            <el-select v-model="form.tempSndj" clearable size="small" placeholder="请选择" style="width: 170px;">
              <el-option
                v-for="item in sndjTypeOptions"
                :key="item.key"
                :label="item.display_name"
                :value="item.key"
              />
            </el-select>
          </el-form-item>
          <el-form-item label="申请原因" prop="bisZhsqSqyy">
            <el-input v-model="form.bisZhsqSqyy" :rows="3" type="textarea" style="width: 470px;" />
          </el-form-item>
          <el-upload
            ref="upload_adl"
            :show-file-list="true"
            :auto-upload="true"
            :on-preview="handlePreview"
            :before-upload="beforeVideoUpload"
            :before-remove="beforeRemove"
            :on-remove="handleRemove"
            :on-success="handleVideoSuccess"
            :on-progress="handleProgress"
            :on-error="handleError"
            :data="fjlb_adl"
            :headers="headers"
            :file-list="file_list_adl"
            :action="formatVideo"
          >
            <el-button size="small" type="primary">上传视频</el-button>
            <span slot="tip" class="el-upload__tip">只能上传视频文件，且不超过150M</span>
          </el-upload>
          <br>
          <el-upload
            ref="upload_sfz"
            :data="fjlb_sfz"
            :headers="headers"
            :action="minnioUploadHomeImage"
            :before-upload="beforeUpload"
            :before-remove="beforeRemove"
            :on-remove="handleRemove"
            :on-success="handleSfzSuccess"
            :on-progress="handleProgress"
            :on-error="handleError"
            :file-list="file_list_sfz"
            list-type="picture"
          >
            <el-button size="small" type="primary">上传身份证（正反面）</el-button>
            <div slot="tip" class="el-upload__tip">只能上传jpg/png文件，且不超过5MB</div>
          </el-upload>
          <br>
          <el-upload
            ref="upload_bl"
            :data="fjlb_bl"
            :headers="headers"
            :action="minnioUploadHomeImage"
            :before-upload="beforeUpload"
            :before-remove="beforeRemove"
            :on-remove="handleRemove"
            :on-success="handleBlSuccess"
            :on-progress="handleProgress"
            :on-error="handleError"
            :file-list="file_list_bl"
            list-type="picture"
          >
            <el-button size="small" type="primary">上传病历</el-button>
            <div slot="tip" class="el-upload__tip">只能上传jpg/png文件，且不超过5MB</div>
          </el-upload>
          <br>
          <el-upload
            ref="upload_shbzk"
            :data="fjlb_shbzk"
            :headers="headers"
            :action="minnioUploadHomeImage"
            :before-upload="beforeUpload"
            :before-remove="beforeRemove"
            :on-remove="handleRemove"
            :on-success="handleYbkSuccess"
            :on-progress="handleProgress"
            :on-error="handleError"
            :file-list="file_list_shbzk"
            list-type="picture"
          >
            <el-button size="small" type="primary">上传社会保障卡（正反面）</el-button>
            <div slot="tip" class="el-upload__tip">只能上传jpg/png文件，且不超过5MB</div>
          </el-upload>
        </el-form>
        <div slot="footer" class="dialog-footer">
          <el-button @click="snDelayDialog = false">取消</el-button>
          <el-button type="primary" @click="doSave('00')">保存</el-button>
          <el-button type="success" @click="doSubmit('11')">提交</el-button>
        </div>
      </el-dialog>

      <!--表格渲染-->
      <el-dialog :visible.sync="ssxqDisabled" :title="crud.status.title" width="660px">
        <el-form ref="form" :inline="true" :model="form" :rules="rules" size="small" label-width="110px">
          <el-form-item label="姓名" prop="bisZhsqSnryXm">
            <el-input v-model="form.bisZhsqSnryXm" disabled style="width: 170px;" />
          </el-form-item>
          <el-form-item label="身份证" prop="bisZhsqSnrySfz">
            <el-input v-model="form.bisZhsqSnrySfz" disabled style="width: 170px;" />
          </el-form-item>
          <el-form-item label="性别" prop="bisZhsqSnryXb">
            <el-input v-model="form.bisZhsqSnryXb" disabled style="width: 170px;" />
          </el-form-item>
          <el-form-item label="年龄" prop="bisZhsqNl">
            <el-input v-model="form.bisZhsqNl" disabled style="width: 170px;" />
          </el-form-item>
          <el-form-item label="医保卡号" prop="bisZhsqYbkh">
            <el-input v-model="form.bisZhsqYbkh" disabled style="width: 170px;" />
          </el-form-item>
          <el-form-item label="参保状态" prop="bisZhsqCbzt">
            <el-input v-model="form.bisZhsqCbzt" disabled style="width: 170px;" />
          </el-form-item>
          <el-form-item label="参保类型" prop="bisZhsqCblx">
            <el-input v-model="form.bisZhsqCblx" disabled style="width: 170px;" />
          </el-form-item>
          <el-form-item label="医保所属区县" prop="bisZhsqSnryYbssqx">
            <el-select v-model="form.bisZhsqSnryYbssqx" filterable placeholder="请选择" disabled style="width: 170px;">
              <el-option
                v-for="item in dict.ccstcqh"
                :key="item.id"
                :label="item.label"
                :value="item.value"
              />
            </el-select>
          </el-form-item>
          <el-form-item label="行政区划" prop="districts">
            <el-select v-model="form.bisZhsqHldzSsqx" placeholder="请选择" style="width: 170px;">
              <el-option
                v-for="item in districts"
                :key="item.value"
                :label="item.label"
                :value="item.value"
              />
            </el-select>
          </el-form-item>
        </el-form>
        <div slot="footer" class="dialog-footer">
          <el-button @click="ssxqDisabled = false">关 闭</el-button>
          <el-button v-loading.fullscreen.lock="fullscreenLoading" type="info" @click="saveSsxq()">保 存</el-button>
        </div>
      </el-dialog>

      <!--表格渲染-->
      <el-table ref="table" v-loading="crud.loading" :data="crud.data" size="small" style="width: 100%;" @selection-change="crud.selectionChangeHandler">
        <el-table-column type="selection" width="55" />
        <el-table-column align="center" prop="bisZhsqZt" label="申请状态" width="130">
          <template slot-scope="scope">
            <el-tag v-if="scope.row.bisZhsqZt === '05'" effect="plain" type="">
              {{ dict.label.zhzt[scope.row.bisZhsqZt] }}
            </el-tag>
            <el-tag v-else-if="scope.row.bisZhsqZt === '00'" effect="plain" type="warning">
              {{ dict.label.zhzt[scope.row.bisZhsqZt] }}
            </el-tag>
            <el-tag v-else effect="plain" type="danger">
              {{ dict.label.zhzt[scope.row.bisZhsqZt] }}
            </el-tag>
          </template>
        </el-table-column>
        <el-table-column align="center" prop="lrsj" label="申请时间" width="150" />
        <el-table-column align="center" prop="bisZhsqYbkh" label="医保卡号" width="90" />
        <el-table-column align="center" prop="bisZhsqSnryXm" label="姓名" />
        <el-table-column align="center" prop="bisZhsqSnryXb" label="性别" />
        <el-table-column align="center" prop="bisZhsqSnrySfz" label="身份证" width="150" />
        <el-table-column align="center" prop="bisZhsqNl" label="年龄" />
        <el-table-column prop="bisZhsqDykkrq" label="待遇开始日期" width="100" />
        <el-table-column prop="bisZhsqDyjsrq" label="待遇结束日期" width="100" />
        <el-table-column align="center" prop="bisZhsqSndj" label="失能等级" />
        <el-table-column align="center" prop="bisZhsqHldzSsqxName" label="居住所在区县" width="130" />
        <el-table-column align="center" prop="bisZhsqAdl" label="ADL评分" />
        <el-table-column align="center" prop="bisZhsqLxdh" label="联系电话" width="100" />
        <el-table-column align="center" prop="bisZhsqJhrxm" label="监护人姓名" />
        <el-table-column align="center" prop="bisZhsqJhrdh" label="监护人电话" width="130" />
        <el-table-column align="center" prop="bisZhsqGxName" label="关系" />
        <el-table-column align="center" prop="bisZhsqSnryYbssqxName" label="医保所属区县" width="130" />
        <el-table-column fixed="right" label="操作" width="290px" align="center">
          <template slot-scope="scope">
            <el-button
              size="mini"
              type="success"
              icon="el-icon-s-operation"
              @click.native.prevent="toDelay(scope.row)"
            >
              延期
            </el-button>
            <el-button
              size="mini"
              type="success"
              icon="el-icon-sort"
              @click.native.prevent="to90(scope.row)"
            >
              转90
            </el-button>
            <el-button
              size="mini"
              type="success"
              icon="el-icon-set-up"
              @click.native.prevent="toChange(scope.row)"
            >
              变更
            </el-button>
            <el-button
              size="mini"
              type="success"
              icon="el-icon-receiving"
              @click.native.prevent="toFp(scope.row)"
            >
              复评
            </el-button>
            <el-button
              type="primary"
              size="small"
              icon="el-icon-view"
              @click.native.prevent="recall(scope.$index, scope.row)"
            >
              查 看
            </el-button>
            <!--
            <el-button
              type="info"
              size="small"
              @click.native.prevent="callSsxq(scope.$index, scope.row)"
            >
              维护行政区划
            </el-button>-->
          </template>
        </el-table-column>
      </el-table>
      <!--分页组件-->
      <pagination />
      <el-dialog :visible.sync="dialogYjFormVisible" width="720px">
        <el-table ref="yjtable" v-loading="zhHistoryDataloading" :data="zhHistoryData">
          <el-table-column type="index" :index="indexMethod" label="序号" align="center" />
          <el-table-column prop="lrsj" label="操作时间" align="center" />
          <el-table-column prop="lrrxm" label="操作人" align="center" />
          <el-table-column prop="type" label="操作类型" align="center">
            <template slot-scope="scope">
              <el-tag v-if="scope.row.type === '02'" effect="plain" type="success">
                评估
              </el-tag>
              <el-tag v-else-if="scope.row.type === '04'" effect="plain" type="primary">
                复核
              </el-tag>
            </template>
          </el-table-column>
          <el-table-column prop="result" label="操作结果" align="center" />
          <el-table-column prop="bz" label="意见" align="center" width="200px" />
        </el-table>
        <div slot="footer" class="dialog-footer">
          <el-button @click="dialogYjFormVisible = false">关 闭</el-button>
        </div>
      </el-dialog>
      <!--Drawer 抽屉，隐藏ADL量表列表-->
      <el-drawer
        title="ADL量表"
        :visible.sync="adlDrawer"
        :before-close="handleClose"
        direction="rtl"
        size="40%"
      >
        <div v-for="(adlXmItem, adlXmIndex) in adlData" :key="adlXmIndex" style="margin-left: 20px;">
          <div style="margin-bottom: 5px;">{{ (adlXmIndex+1) + "、" + adlXmItem.adlXmName }}</div>
          <div>
            <el-radio-group v-model="adlXmItem.adlXmGroup">
              <div v-for="(adlXmxxItem, adlXmxxIndex) in adlXmItem.adlXmList" :key="adlXmxxIndex" style="margin-left: 10px; margin-bottom: 5px;">
                <el-radio :label="adlXmxxItem.adlXmxxId">{{ adlXmxxItem.adlXmxxName }}({{ adlXmxxItem.adlXmxxFs }}分)</el-radio>
              </div>
            </el-radio-group>
          </div>
        </div>
        <div style="margin-bottom: 20px; margin-top: 10px; margin-left: 58%;">
          <el-button @click="handleClose">取 消</el-button>
          <el-button type="success" @click="adlSubmit">确 认</el-button>
        </div>
      </el-drawer>
      <image-viewer
        v-if="showImgViewer"
        :url-list="imgPreviewUrl"
        :on-close="() => {showImgViewer = false}"
        :z-index="3000"
      />
    </div>
  </div>
</template>

<script>
import crudZhsq from '@/api/business/zhsq'
import zhsqFp from '@/api/business/zhsqFp'
import crudFile from '@/api/tools/localStorage'
import { mapGetters } from 'vuex'
import { getToken } from '@/utils/auth'
import { getYbry } from '@/api/business/ybry'
import { selfAssessment } from '@/api/business/adlXmxx'
import { queryThisHljg } from '@/api/business/hljg'
import CRUD, { presenter, header, form, crud } from '@crud/crud'
import rrOperation from '@crud/RR.operation'
import pagination from '@crud/Pagination'
import moment from 'moment'
import ImageViewer from 'element-ui/packages/image/src/image-viewer'
import axios from 'axios'

const defaultForm = { bisZhsqId: null, bisZhsqHljgId: null, bisZhsqSnryId: null, bisZhsqSnryXm: null, bisZhsqSnryXb: null, bisZhsqSnrySfz: null, bisZhsqDykkrq: null, bisZhsqYbkh: null, bisZhsqCbzt: null, bisZhsqDyjsrq: null, bisZhsqXsdyq: null, bisZhsqAdl: null, bisZhsqZt: null, bisZhsqSnryYbssqx: null, ywlx: null, lrr: null, lrrxm: null, lrbm: null, lrbmmc: null, lrsj: null, gxr: null, gxrxm: null, gxbm: null, gxbmmc: null, gxsj: null, bz: null, bisZhsqAdlPc: null, bisZhsqSndj: null, bisZhsqRybh: null, bisZhsqNl: null, bisZhsqLxdh: null, bisZhsqHldzSsqx: null, bisZhsqHldzXxdz: null, bisZhsqHldz: null, bisZhsqJhrxm: null, bisZhsqJhrdh: null, bisZhsqGx: null, bisZhsqSqyy: null, bisZhsqGrbh: null, adlZhsqs: [], bisZhsqCblx: null, tempNl: null, tempAdlFs: null, tempSndj: null }
export default {
  name: 'ZhsqJgFh',
  components: { pagination, rrOperation, ImageViewer },
  mixins: [presenter(), header(), form(defaultForm), crud()],
  dicts: ['xb', 'yjsgx', 'ccs', 'zhzt', 'ccstcqh'],
  cruds() {
    return CRUD({ title: '照护申请', url: 'api/zhsqQuery/querOrgYfhZhsqxx', idField: 'bisZhsqId', sort: 'bisZhsqId,desc', crudMethod: { ...crudZhsq }})
  },
  data() {
    return {
      dialogYjFormVisible: false,
      snryDrawer: false,
      ybrySfzh: '',
      adlDrawer: false,
      /* ALD选题按钮是否可用 */
      adlIsDisabled: false,
      ssxqDisabled: false,
      glDelayDialog: false,
      snDelayDialog: false,
      snryData: [],
      zhHistoryData: [],
      adlData: [],
      headers: { 'Authorization': getToken() },
      /* 上传附件时，附件类别（病历） */
      fjlb_bl: { 'fjlb': 'BL' },
      /* 上传附件时，附件类别（社会保障卡） */
      fjlb_shbzk: { 'fjlb': 'SHBZK' },
      /* 上传附件时，附件类别（身份证） */
      fjlb_sfz: { 'fjlb': 'SFZ' },
      /* 上传附件时，附件类别（ADL量表） */
      fjlb_adl: { 'fjlb': 'orgAdlLiveVideo' },
      /* 默认加载上传的文件列表 */
      file_list_bl: [],
      file_list_shbzk: [],
      file_list_sfz: [],
      file_list_adl: [],
      districts: [],
      cascaderCheck: [],
      fileIds: '',
      fileVideoIds: '',
      fileSfzds: '',
      fileYbkIds: '',
      fileBlIds: '',
      fileAllIds: '',
      showImgViewer: false,
      imgPreviewUrl: [], // 当前要放大的图片存放位置
      sbIsExist: true,
      pgIsExist: true,
      sstcq: '',
      snryDataloading: false,
      zhHistoryDataloading: false,
      fullscreenLoading: false,
      isSuccess: false,
      fileUploading: false,
      sndjDisabled: true,
      gldjDisabled: true,
      subTip: '',
      radio4: 'ReadCardBas',
      cblxTypeOptions: [
        { key: '城乡居民', display_name: '城乡居民' },
        { key: '城镇职工', display_name: '城镇职工' }
      ],
      sndjTypeOptions: [
        { key: '中度失能', display_name: '中度失能' },
        { key: '重度失能', display_name: '重度失能' }
      ],
      gldjTypeOptions: [
        { key: '85周岁以上', display_name: '85周岁以上' },
        { key: '90周岁以上', display_name: '90周岁以上' }
      ],
      permission: {
        add: ['admin', 'zhsq:add'],
        edit: ['admin', 'zhsq:edit'],
        del: ['admin', 'zhsq:del']
      },
      rules: {
        bisZhsqSnryXm: [
          { required: true, message: '姓名不能为空', trigger: 'blur' }
        ],
        bisZhsqSnryXb: [
          { required: true, message: '性别不能为空', trigger: 'blur' }
        ],
        bisZhsqSnrySfz: [
          { required: true, message: '身份证不能为空', trigger: 'blur' }
        ],
        bisZhsqHldzSsqx: [
          { required: true, message: '行政区划不能为空', trigger: 'blur' }
        ],
        bisZhsqHldz: [
          { required: true, message: '地址不能为空', trigger: 'blur' }
        ],
        bisZhsqJhrxm: [
          { required: true, message: '监护人姓名不能为空', trigger: 'blur' }
        ],
        bisZhsqJhrdh: [
          { required: true, message: '监护人电话不能为空', trigger: 'blur' }
        ],
        bisZhsqGx: [
          { required: true, message: '与失能人员关系不能为空', trigger: 'blur' }
        ],
        bisZhsqSqyy: [
          { required: true, message: '申请原因不能为空', trigger: 'blur' }
        ],
        bisZhsqAdl: [
          { required: true, message: '选择ADL量表', trigger: 'blur' }
        ],
        bisZhsqSndj: [
          { required: true, message: '选择失能等级', trigger: 'blur' }
        ],
        tempAdlFs: [
          { required: true, message: '选择ADL量表', trigger: 'blur' }
        ],
        tempSndj: [
          { required: true, message: '选择失能等级', trigger: 'blur' }
        ]
      }
    }
  },
  computed: {
    ...mapGetters([
      'baseApi',
      'fileUploadApi',
      'minioUploadImageApi',
      'minioMpUploadImageApi',
      'minnioUploadHomeImage',
      'formatVideo',
      'minioUploadVideoApi',
      'minioMpUploadVideoApi',
      'imagesUploadApi',
      'user'
    ])
  },
  methods: {
    // 钩子：在获取表格数据之前执行，false 则代表不获取数据
    [CRUD.HOOK.beforeRefresh]() {
      return true
    },
    /**
     * 点击新建/编辑之前
     * @param crud
     * @param form
     * @returns {boolean}
     */
    [CRUD.HOOK.beforeToCU]() {
      this.queryThisHljg()
      return true
    },
    /**
     * 点击新建之前
     * @param crud
     * @param form
     * @returns {boolean}
     */
    [CRUD.HOOK.beforeToAdd]() {
      this.adlIsDisabled = false
      this.file_list_bl = []
      this.file_list_shbzk = []
      this.file_list_sfz = []
      this.file_list_adl = []
      this.fileAllIds = ''
      this.fileIds = ''
      this.fileVideoIds = ''
      this.fileSfzds = ''
      this.fileYbkIds = ''
      this.fileBlIds = ''
      return true
    },
    /**
     * 点击修改之前
     * @param crud
     * @param form
     * @returns {boolean}
     */
    [CRUD.HOOK.beforeToEdit](crud, form) {
      console.log(form)
      return true
    },
    /**
     * 点击删除之前校验
     * @param crud
     * @param form
     * @returns {boolean}
     */
    [CRUD.HOOK.beforeDelete](crud, form) {

    },
    /**
     * 序号
     * @param index
     * @returns {*}
     */
    indexMethod(index) {
      return index + 1
    },
    /**
     * 撤回
     * @param index
     * @param rows
     */
    recall(index, rows) {
      this.crud.toEdit(rows)
    },
    /**
     * 延期
     */
    toDelay(row) {
      console.log(row)
      const currentSndj = row.bisZhsqSndj
      this.subTip = '延期申请'
      this.file_list_bl = []
      this.file_list_shbzk = []
      this.file_list_sfz = []
      this.file_list_adl = []
      this.fileAllIds = ''
      this.fileIds = ''
      this.fileVideoIds = ''
      this.fileSfzds = ''
      this.fileYbkIds = ''
      this.fileBlIds = ''

      const csnd = row.bisZhsqSnrySfz.substring(6, 10)
      const csrq = row.bisZhsqSnrySfz.substring(10, 14)
      // const csnd = 1937
      // const csrq = 1208
      const currentNd = moment(new Date()).format('YYYY')
      const currentRq = moment(new Date()).format('MMDD')
      // 当前日期 >= 出生日期的，年龄+1
      const nl = currentRq >= csrq ? currentNd - csnd : currentNd - csnd - 1

      // 清空附件列表
      this.getFiles(row.bisZhsqId)
      this.queryAllQyJd()
      crudZhsq.calculateOrgDelayDays(row.bisZhsqId)
        .then(res => {
          console.log(res)
          if (res <= 29) {
            if (currentSndj === '85周岁以上' || currentSndj === '90周岁以上') {
              this.glDelayDialog = true
            } else {
              this.snDelayDialog = true
            }
            this.form = row
            this.form.bisZhsqSnryYbssqx = row.bisZhsqSnryYbssqxCode
            this.form.tempNl = nl
          } else {
            this.$notify({
              title: '延期申请，需在待遇结束日期前30个自然日以内',
              type: 'warning',
              duration: 2500
            })
          }
        })
        .catch(err => {
          console.log(err)
        })
      // this.form.bisZhsqId = null
    },
    /**
     * 转90周岁
     */
    to90(row) {
      console.log(row)
      const currentSndj = row.bisZhsqSndj
      this.subTip = '转90周岁以上申请'
      this.file_list_bl = []
      this.file_list_shbzk = []
      this.file_list_sfz = []
      this.file_list_adl = []
      this.fileAllIds = ''
      this.fileIds = ''
      this.fileVideoIds = ''
      this.fileSfzds = ''
      this.fileYbkIds = ''
      this.fileBlIds = ''

      const csnd = row.bisZhsqSnrySfz.substring(6, 10)
      const csrq = row.bisZhsqSnrySfz.substring(10, 14)
      // const csnd = 1937
      // const csrq = 1208
      const currentNd = moment(new Date()).format('YYYY')
      const currentRq = moment(new Date()).format('MMDD')
      // 当前日期 >= 出生日期的，年龄+1
      const nl = currentRq >= csrq ? currentNd - csnd : currentNd - csnd - 1
      // const nl = 90

      if (currentSndj !== '85周岁以上') {
        this.$notify({
          title: '此模块是85周岁以上转90周岁以上，失能等级变更，请点击【变更】按钮',
          type: 'warning',
          duration: 2500
        })
        return
      }
      if (nl !== 90) {
        this.$notify({
          title: row.bisZhsqSnryXm + '[' + row.bisZhsqSnrySfz + ']老人尚未到90周岁',
          type: 'warning',
          duration: 2500
        })
        return
      }
      this.glDelayDialog = true
      this.form = row
      this.form.bisZhsqSnryYbssqx = row.bisZhsqSnryYbssqxCode
      this.form.tempSndj = '90周岁以上'
      this.form.tempNl = nl

      // 清空附件列表
      this.getFiles(row.bisZhsqId)
      this.queryAllQyJd()
    },
    /**
     * 失能等级变更
     */
    toChange(row) {
      console.log(row)
      const currentSndj = row.bisZhsqSndj
      this.subTip = '失能等级变更申请'
      this.file_list_bl = []
      this.file_list_shbzk = []
      this.file_list_sfz = []
      this.file_list_adl = []
      this.fileAllIds = ''
      this.fileIds = ''
      this.fileVideoIds = ''
      this.fileSfzds = ''
      this.fileYbkIds = ''
      this.fileBlIds = ''

      const csnd = row.bisZhsqSnrySfz.substring(6, 10)
      const csrq = row.bisZhsqSnrySfz.substring(10, 14)
      // const csnd = 1937
      // const csrq = 1208
      const currentNd = moment(new Date()).format('YYYY')
      const currentRq = moment(new Date()).format('MMDD')
      // 当前日期 >= 出生日期的，年龄+1
      const nl = currentRq >= csrq ? currentNd - csnd : currentNd - csnd - 1

      if (currentSndj === '85周岁以上' || currentSndj === '90周岁以上') {
        this.snDelayDialog = true
        this.sndjDisabled = false
      } else {
        this.glDelayDialog = true
        this.gldjDisabled = false
      }

      this.form = row
      this.form.bisZhsqSnryYbssqx = row.bisZhsqSnryYbssqxCode
      this.form.tempNl = nl

      // 清空附件列表
      this.getFiles(row.bisZhsqId)
      this.queryAllQyJd()
    },
    /**
     * 提出复评
     */
    toFp(row) {
      console.log(row)
      this.form = row
      this.$confirm(`自评估结论15个工作日以内，可以提出复评申请。<br>` +
        `复评评估结论和原评估结论的相同的，维持原评估结论；<br>` +
        `复评评估结论比原评估结论严重的，原评估结论终止，以复评评估结论为准。复评评估结论为最终评估结论`, '提示', {
        confirmButtonText: '确定',
        cancelButtonText: '取消',
        type: 'warning',
        dangerouslyUseHTMLString: true // 启用 HTML 解析
      }).then(async() => {
        this.fullscreenLoading = true
        await zhsqFp.getFpTargetDate(row.bisZhsqId)
          .then(res => {
            const current = moment(new Date()).format('YYYY-MM-DD')
            const pgrq = moment(row.pgsj).format('YYYY-MM-DD')
            const pgjl = moment(row.pgsj).add(5, 'days').format('YYYY-MM-DD')
            const pglast = moment(res).format('YYYY-MM-DD')
            if (pglast >= current) {
              zhsqFp.exeFp(row.bisZhsqId)
                .then(res => {
                  this.fullscreenLoading = false
                  this.$notify({
                    title: '提出复评申请成功，等待评估人员上门评估',
                    type: 'success',
                    duration: 2500
                  })
                })
                .catch(err => {
                  this.fullscreenLoading = false
                  console.log(err)
                })
            } else {
              this.fullscreenLoading = false
              this.$alert(`评估日期为[${pgrq}]<br>评估结论为[${pgjl}]<br>评估结论第15个工作日[${pglast}]<br>` +
                `当前日期[${current}]已超过[${pglast}]，不允许提出复评。`, '提 醒', {
                confirmButtonText: '确定',
                dangerouslyUseHTMLString: true // 启用 HTML 解析
              })
            }
            console.log(current)
            console.log(pglast)
          })
          .catch(err => {
            this.fullscreenLoading = false
            console.log(err)
          })
      })
    },
    callSsxq(index, rows) {
      this.ssxqDisabled = true
      this.form.bisZhsqHldzSsqx = rows.bisZhsqHldzSsqxCode === '' ? '' : rows.bisZhsqHldzSsqxCode
      this.queryAllQyJd()
      console.log(rows)
      console.log(this.form)
      this.form.bisZhsqId = rows.bisZhsqId
      this.form.bisZhsqSnryXm = rows.bisZhsqSnryXm
      this.form.bisZhsqSnrySfz = rows.bisZhsqSnrySfz
      this.form.bisZhsqSnryXb = rows.bisZhsqSnryXb
      this.form.bisZhsqNl = rows.bisZhsqNl
      this.form.bisZhsqCbzt = rows.bisZhsqCbzt
      this.form.bisZhsqYbkh = rows.bisZhsqYbkh
      this.form.bisZhsqSnryYbssqx = rows.bisZhsqSnryYbssqxCode
      this.form.bisZhsqCblx = rows.bisZhsqCblx
    },
    saveSsxq() {
      if (this.form.bisZhsqHldzSsqx === undefined || this.form.bisZhsqHldzSsqx === '' || this.form.bisZhsqHldzSsqx === null) {
        this.$notify({
          title: '请选择行政区划',
          type: 'warning',
          duration: 2500
        })
        return
      }
      this.fullscreenLoading = true
      crudZhsq.updateOnlyZhsq(this.form)
        .then(res => {
          this.fullscreenLoading = false
          this.ssxqDisabled = false
          this.$notify({
            title: '已保存',
            type: 'success',
            duration: 2500
          })
          this.crud.toQuery()
        })
        .catch(err => {
          this.fullscreenLoading = false
          this.ssxqDisabled = false
          console.log(err)
        })
    },
    /**
     * 确认选择的失能人员
     * @param index
     * @param rows
     */
    selectRow(index, rows) {
      const snry = rows[index]
      console.log(snry)

      if (!(snry.aab034Code === this.sstcq || snry.aab034Code === '220101')) {
        this.$message({
          showClose: true,
          message: '此人医保所属统筹区为【' + snry.aab034Name + '】，本院为【' + this.dict.label.ccstcqh[this.sstcq] + '】，不符合申请条件',
          type: 'warning'
        })
        return
      }

      // 校验参保状态
      if (snry.aac031 === '停保') {
        this.$message({
          showClose: true,
          message: '此人【已停保】，无法申请照护待遇',
          type: 'warning'
        })
        return
      }
      // 校验是否缴费
      if (snry.clctClag === '') {
        this.$message({
          showClose: true,
          message: '此人【未缴费】，无法申请照护待遇',
          type: 'warning'
        })
        return
      }
      // 校验人员类型
      if (snry.akc021 === '离休或一级保健对象') {
        this.$message({
          showClose: true,
          message: '人员类型为【离休或一级保健对象】，无法申请照护待遇',
          type: 'warning'
        })
        return
      }
      // 校验是否住院
      // 校验是否正在享受待遇
      if (snry.akb021 !== '') {
        this.$message({
          showClose: true,
          message: '此人正在【' + snry.akb021 + '】享受照护待遇，无法申请',
          type: 'warning'
        })
        return
      }
      this.snryDrawer = false

      // const csrq = snry.aac002.substring(6, 13)
      const csnd = snry.aac002.substring(6, 10)
      const csrq = snry.aac002.substring(10, 14)
      // const csnd = 1937
      // const csrq = 1208
      const currentNd = moment(new Date()).format('YYYY')
      const currentRq = moment(new Date()).format('MMDD')
      // 当前日期 >= 出生日期的，年龄+1
      const nl = currentRq >= csrq ? currentNd - csnd : currentNd - csnd - 1

      this.form.bisZhsqGrbh = snry.aac001
      this.form.bisZhsqSnryXm = snry.aac003
      this.form.bisZhsqSnryXb = snry.xb
      this.form.bisZhsqSnrySfz = snry.aac002
      this.form.bisZhsqYbkh = snry.cardno
      this.form.bisZhsqCbzt = snry.aac031
      this.form.bisZhsqCblx = snry.aac008
      this.form.bisZhsqNl = nl
      // this.form.bisZhsqNl = 85
      this.form.bisZhsqSnryYbssqx = snry.aab034Code
      console.log('nl {} ', this.form.bisZhsqNl)
      this.form.bisZhsqAdl = this.form.bisZhsqNl >= 85 ? 100 : this.form.bisZhsqAdl
    },
    /**
     * 打开失能人员时，实时查询
     */
    getSnry() {
      this.snryDrawer = true
      this.ybrySfzh = ''
      this.snryData = []
    },
    /**
     * 查询医保人员
     */
    ybryQuery() {
      if (this.ybrySfzh === '') {
        this.$message({
          showClose: true,
          message: '请输入查询条件',
          type: 'warning'
        })
        return
      }

      if (this.ybrySfzh.length !== 18) {
        this.$message({
          showClose: true,
          message: '身份证不正确',
          type: 'warning'
        })
        return
      }

      this.snryDataloading = true
      getYbry({ sfzh: this.ybrySfzh }).then(res => {
        this.snryData = res.content
        this.snryDataloading = false
      }).catch(err => {
        this.snryDataloading = false
        console.log(err.data.message)
      })
    },
    /**
     * 查询医保人员
     */
    zhHistoryQuery() {
      this.dialogYjFormVisible = true
      console.log(this.zhHistoryData.length === 0)
      this.zhHistoryDataloading = true
      crudZhsq.getZhHistory({ zhsqId: this.form.bisZhsqId, sort: 'lrsj,desc' }).then(res => {
        console.log(res)
        this.zhHistoryData = res.content
        this.zhHistoryDataloading = false
      }).catch(err => {
        this.zhHistoryDataloading = false
        console.log(err.data.message)
      })
    },
    /**
     * 打开ADL量表时，实时查询
     */
    getAdl() {
      if (this.adlIsDisabled) {
        this.$message({
          dangerouslyUseHTMLString: true,
          showClose: true,
          message: 'ADL量表已完成，修改时无法操作',
          type: 'warning'
        })
      } else {
        this.adlDrawer = true
        selfAssessment().then(res => {
          console.log(res)
          this.adlData = res.adlData
          this.form.bisZhsqAdlPc = res.adlPcId
        })
      }
    },
    /**
     * 修改操作时，需要加载附件信息
     */
    getFiles(bisZhsqId) {
      crudFile.queryFileByFjlb2(bisZhsqId).then(res => {
        for (let i = 0; i < res.length; i++) {
          const file = res[i]
          if (file.fjlb === 'SFZ') {
            const obj = { 'id': file.id, 'name': file.name, 'url': file.path2 }
            this.file_list_sfz.push(obj)
            this.fileSfzds += file.id + ','
          }
          if (file.fjlb === 'SHBZK') {
            const obj = { 'id': file.id, 'name': file.name, 'url': file.path2 }
            this.file_list_shbzk.push(obj)
            this.fileYbkIds += file.id + ','
          }
          if (file.fjlb === 'BL') {
            const obj = { 'id': file.id, 'name': file.name, 'url': file.path2 }
            this.file_list_bl.push(obj)
            this.fileBlIds += file.id + ','
          }
        }
      })
    },
    /**
     * 记录ADL量表，并计算ADL量表总分数
     */
    async adlSubmit() {
      // 是否被选中
      let selected = false
      // 未被选中的项目
      let allUnSelectedName = ''
      // ADL量表总分数
      // 清空选中的adl量表内容
      this.form.adlZhsqs = []

      const that = this
      this.adlData.map((item, index) => {
        // 项目ID
        const adlXmId = item.adlXmId
        // 项目分组
        const adlXmGroup = item.adlXmGroup
        // 项目名称
        const adlXmName = item.adlXmName
        // 项目名称
        const adlXmPx = item.adlXmPx
        // 项目选项列表
        const adlXmList = item.adlXmList

        if (adlXmId === adlXmGroup) {
          selected = selected || true
          allUnSelectedName += adlXmPx + '、' + adlXmName + '<br>'
        } else {
          for (const adlxmxx of adlXmList) {
            adlxmxx.adlXmId = adlXmId
            // 项目选项ID
            const adlXmxxId = adlxmxx.adlXmxxId
            // 项目选项分数
            if (adlXmGroup === adlXmxxId) {
              this.form.adlZhsqs.push(adlxmxx)
            }
          }
        }
        // eslint-disable-next-line no-empty
      })
      console.log('总分：' + JSON.stringify(this.form))
      if (selected) {
        this.$message({
          dangerouslyUseHTMLString: true,
          showClose: true,
          message: allUnSelectedName + '<br>没有被选中',
          type: 'warning'
        })
      } else {
        await crudZhsq.getSelfAnalyse(this.form)
          .then(res => {
            that.form.tempAdlFs = res
            console.log('adlSubmit res:', res)
            console.log('adlSubmit tempAdlFs:', that.form.tempAdlFs)
          })
          .catch(err => {
            console.log(err)
          })
        this.adlDrawer = false
      }
    },
    /**
     * 自定义保存
     * @param zt
     */
    async doSave(zt) {
      console.log('doSave tempAdlFs:', this.form.tempAdlFs)
      console.log('doSave tempSndj:', this.form.tempSndj)
      if (this.form.tempSndj === '中度失能' || this.form.tempSndj === '重度失能') {
        if (this.form.tempAdlFs === 'A级' || this.form.tempAdlFs === 'B级' || this.form.tempAdlFs === 'C级' || this.form.tempAdlFs === 'D级') {
          this.$notify({
            title: '自评结果不允许申请',
            type: 'error',
            duration: 2500
          })
          return
        }
      }
      const tipSndj = (this.form.tempSndj === '中度失能' || this.form.tempSndj === '重度失能') ? '失能' : '高龄'
      this.fileAllIds = this.fileVideoIds + this.fileSfzds + this.fileBlIds + this.fileYbkIds
      const titleMsg = '保存成功'
      await this.crud.findVM('form').$refs['form'].validate(valid => {
        console.log('doSave validate:', valid)
        if (!valid) {
          return
        }
        const now = moment()
        let yesterday = now.add(-1, 'days')
        yesterday = yesterday.format('YYYY-MM-DD')
        const current = moment().format('YYYY-MM-DD')

        this.$confirm(`确定<span style="color: red">保存</span>${this.subTip}吗？<br>${this.form.bisZhsqSnryXm}当前待遇期为${this.form.bisZhsqDykkrq}至${this.form.bisZhsqDyjsrq}<br>` +
          `延期以后待遇期为${this.form.bisZhsqDykkrq}至${yesterday}并过期<br>` +
          `延期申请的待遇以${current}开始，在申请${tipSndj}菜单中可以查看到`, '提示', {
          confirmButtonText: '确定',
          cancelButtonText: '取消',
          type: 'warning',
          dangerouslyUseHTMLString: true // 启用 HTML 解析
        }).then(() => {
          this.form.bisZhsqZt = zt
          this.form.bisZhsqAdl = this.form.tempAdlFs
          this.form.bisZhsqSndj = this.form.tempSndj
          this.form.tempSndj = this.form.tempNl
          this.fullscreenLoading = true
          if (this.form.tempSndj === '中度失能' || this.form.tempSndj === '重度失能') {
            console.log('中度失能,重度失能')
            crudZhsq.addSn(this.form, this.fileAllIds, '1')
              .then(res => {
                console.log('crudZhsq.addSn res', res)
                this.fullscreenLoading = false
                this.snDelayDialog = false
                this.glDelayDialog = false
                this.$notify({
                  title: titleMsg,
                  type: 'success',
                  duration: 2500
                })
                this.crud.toQuery()
              })
              .catch(err => {
                this.fullscreenLoading = false
                console.log(err)
              })
          } else {
            console.log('85,90')
            crudZhsq.addGl(this.form, this.fileAllIds, '1')
              .then(res => {
                console.log('crudZhsq.addGl res', res)
                this.fullscreenLoading = false
                this.snDelayDialog = false
                this.glDelayDialog = false
                console.log('this.glDelayDialog', this.glDelayDialog)
                this.$notify({
                  title: titleMsg,
                  type: 'success',
                  duration: 2500
                })
                this.crud.toQuery()
              })
              .catch(err => {
                this.fullscreenLoading = false
                console.log(err)
              })
          }
        })
      })
    },
    /**
     * 自定义保存
     * @param zt
     */
    doSubmit(zt) {
      console.log('doSubmit tempAdlFs:', this.form.tempAdlFs)
      console.log('doSubmit tempSndj:', this.form.tempSndj)
      if (this.fileYbkIds === '') {
        this.$notify({
          title: '提交时，需要上传医保卡',
          type: 'error',
          duration: 2500
        })
        return
      }
      if (this.fileSfzds === '') {
        this.$notify({
          title: '提交时，需要上传身份证',
          type: 'error',
          duration: 2500
        })
        return
      }
      if (this.form.tempSndj === '中度失能' || this.form.tempSndj === '重度失能') {
        if (this.form.tempAdlFs === 'A级' || this.form.tempAdlFs === 'B级' || this.form.tempAdlFs === 'C级' || this.form.tempAdlFs === 'D级') {
          this.$notify({
            title: '自评结果不允许申请',
            type: 'error',
            duration: 2500
          })
          return
        }
        if (this.fileBlIds === '') {
          this.$notify({
            title: '提交时，需要上传病历',
            type: 'error',
            duration: 2500
          })
          return
        }
        if (this.fileVideoIds === '') {
          this.$notify({
            title: '提交时，需要上传视频',
            type: 'error',
            duration: 2500
          })
          return
        }
      }
      const tipSndj = (this.form.tempSndj === '中度失能' || this.form.tempSndj === '重度失能') ? '失能' : '高龄'
      this.fileAllIds = this.fileVideoIds + this.fileSfzds + this.fileBlIds + this.fileYbkIds
      const titleMsg = '提交成功'
      this.crud.findVM('form').$refs['form'].validate(valid => {
        if (!valid) {
          return
        }
        const now = moment()
        let yesterday = now.add(-1, 'days')
        yesterday = yesterday.format('YYYY-MM-DD')
        const current = moment().format('YYYY-MM-DD')

        this.$confirm(`确定<span style="color: red">提交</span>${this.subTip}吗？<br>${this.form.bisZhsqSnryXm}当前待遇期为${this.form.bisZhsqDykkrq}至${this.form.bisZhsqDyjsrq}<br>` +
          `延期以后待遇期为${this.form.bisZhsqDykkrq}至${yesterday}并过期<br>` +
          `延期申请的待遇以${current}开始，在申请${tipSndj}菜单中可以查看到`, '提示', {
          confirmButtonText: '确定',
          cancelButtonText: '取消',
          type: 'warning',
          dangerouslyUseHTMLString: true // 启用 HTML 解析
        }).then(() => {
          this.form.bisZhsqZt = zt
          this.form.bisZhsqAdl = this.form.tempAdlFs
          this.form.bisZhsqSndj = this.form.tempSndj
          this.form.tempSndj = this.form.tempNl
          this.fullscreenLoading = true
          if (this.form.tempSndj === '中度失能' || this.form.tempSndj === '重度失能') {
            crudZhsq.submitSn(this.form, this.fileAllIds, '1')
              .then(res => {
                this.fullscreenLoading = false
                this.snDelayDialog = false
                this.glDelayDialog = false
                this.$notify({
                  title: titleMsg,
                  type: 'success',
                  duration: 2500
                })
                this.crud.toQuery()
              })
              .catch(err => {
                this.fullscreenLoading = false
                console.log(err)
              })
          } else {
            crudZhsq.submitGl(this.form, this.fileAllIds, '1')
              .then(res => {
                this.fullscreenLoading = false
                this.snDelayDialog = false
                this.glDelayDialog = false
                this.$notify({
                  title: titleMsg,
                  type: 'success',
                  duration: 2500
                })
                this.crud.toQuery()
              })
              .catch(err => {
                this.fullscreenLoading = false
                console.log(err)
              })
          }
        })
      })
    },
    /**
     * ADL量表关闭
     */
    handleClose() {
      this.$confirm('关闭以后，选择的内容将会消失，确认关闭？')
        .then(_ => {
          this.adlDrawer = false
        })
        .catch(_ => {})
    },
    /**
     * 上传前校验
     * @param file
     * @returns {boolean}
     */
    beforeUpload(file) {
      let isLt2M = true
      isLt2M = file.size / 1024 / 1024 < 10
      if (!isLt2M) {
        this.loading = false
        this.$message.error('上传文件大小不能超过 10MB!' + (file.size / 1024 / 1024))
      }
      return isLt2M
    },
    /**
     * 视频上传前校验
     * @param file
     * @returns {boolean}
     */
    beforeVideoUpload(file) {
      let isLt2M = true
      isLt2M = file.size / 1024 / 1024 < 150
      if (!isLt2M) {
        this.loading = false
        // this.$message.error('上传文件大小不能超过 200MB!' + (file.size / 1024 / 1024))
        this.$notify({
          title: '上传文件大小不能超过 150MB!',
          type: 'error',
          duration: 5000
        })
      }
      return isLt2M
    },
    /**
     * 删除前确认提示
     * @param file
     * @returns {Promise<MessageBoxData>}
     */
    beforeRemove(file) {
      console.log('删除前确认提示 :{}', file)
      return this.$confirm(`删除操作会直接删除此图片，确定删除 ${file.name}？`)
    },
    /**
     * 图片预览
     * @param file
     */
    handlePreview(file) {
      console.log('图片预览 :{}', file)
      if (file.response) {
        this.imgPreviewUrl[0] = file.response.data.url2
        window.open(file.response.data.url2)
      } else {
        this.imgPreviewUrl[0] = file.url
        window.open(file.url)
      }
    },
    /**
     * 文件上传成功时的钩子
     * @param response
     * @param file
     * @param fileList
     */
    handleSuccess(response, file, fileList) {
      console.log('文件上传成功时的钩子response :{}, file{}', response, file)
      this.fileIds += response.data.id + ','
      this.crud.notify('上传成功', CRUD.NOTIFICATION_TYPE.SUCCESS)
    },
    /**
     * 视频上传成功时的钩子
     * @param response
     * @param file
     * @param fileList
     */
    handleVideoSuccess(response, file, fileList) {
      console.log('文件上传成功时的钩子response :{}, file{}', response, file)
      this.fileVideoIds += response.data.id + ','

      // crudFile.updateYwid2ById(response.data.adlXmGroup, file.data.id).then(res => {})
      this.crud.notify('上传成功', CRUD.NOTIFICATION_TYPE.SUCCESS)
    },
    /**
     * 图片上传成功时的钩子
     * @param response
     * @param file
     * @param fileList
     */
    handleSfzSuccess(response, file, fileList) {
      console.log('文件上传成功时的钩子response :{}, file{}', response, file)
      this.fileSfzds += response.data.id + ','

      // crudFile.updateYwid2ById(response.data.adlXmGroup, file.data.id).then(res => {})
      this.crud.notify('上传成功', CRUD.NOTIFICATION_TYPE.SUCCESS)
      this.isSuccess = true
      this.fileUploading = false
    },
    /**
     * 图片上传成功时的钩子
     * @param response
     * @param file
     * @param fileList
     */
    handleYbkSuccess(response, file, fileList) {
      console.log('文件上传成功时的钩子response :{}, file{}', response, file)
      this.fileYbkIds += response.data.id + ','

      // crudFile.updateYwid2ById(response.data.adlXmGroup, file.data.id).then(res => {})
      this.crud.notify('上传成功', CRUD.NOTIFICATION_TYPE.SUCCESS)
      this.isSuccess = true
      this.fileUploading = false
    },
    /**
     * 图片上传成功时的钩子
     * @param response
     * @param file
     * @param fileList
     */
    handleBlSuccess(response, file, fileList) {
      console.log('文件上传成功时的钩子response :{}, file{}', response, file)
      this.fileBlIds += response.data.id + ','

      // crudFile.updateYwid2ById(response.data.adlXmGroup, file.data.id).then(res => {})
      this.crud.notify('上传成功', CRUD.NOTIFICATION_TYPE.SUCCESS)
      this.isSuccess = true
      this.fileUploading = false
    },
    handleProgress(event) {
      console.log(event)
      this.fileUploading = true
    },
    /**
     * 移除文件
     * @param file
     * @param fileList
     */
    handleRemove(file, fileList) {
      console.log('移除文件 :{}', file, fileList)
      crudFile.del([file.id]).then(res => {})
    },
    /**
     * 监听上传失败
     * @param e
     * @param file
     * @param fileList
     */
    handleError(e, file, fileList) {
      const msg = JSON.parse(e.message)
      this.$notify({
        title: msg.message,
        type: 'error',
        duration: 2500
      })
      this.loading = false
    },
    /**
     * 查询本机构，是否绑定对应的商保/评估公司
     * false：未绑定；true：绑定
     */
    queryThisHljg() {
      queryThisHljg().then(res => {
        this.sbIsExist = res.sbIsExist
        this.pgIsExist = res.pgIsExist
        this.sstcq = res.sstcq
      })
    },
    queryAllQyJd() {
      crudZhsq.queryAllQyJd().then(res => {
        console.log('res: {} ', res)
        var a = []
        for (const item of res) {
          item.label = item.bisQyName
          item.value = item.bisQyRowId
          for (const child of item.children) {
            child.label = child.bisQyName
            child.value = child.bisQyRowId
          }
          a.push(item)
        }
        this.districts = a
      })
    },
    onchange(e) {
      console.log('选择的区/县街道:{}', e)
      this.form.bisZhsqHldzSsqx = e[0]
    },
    // 获取弹窗内评估公司数据
    read() {
      this.fullscreenLoading = true
      axios.get('http://127.0.0.1:19995?MSG=' + this.radio4).then(res => {
        this.fullscreenLoading = false
        if (this.radio4 === 'ReadCardBas') {
          const shbzkContent = res.data.pCardInfo
          if (shbzkContent === '') {
            this.$notify({
              title: '重新读卡',
              type: 'warning',
              duration: 2500
            })
            return
          } else {
            const contentList = shbzkContent.split('|')
            this.ybrySfzh = contentList[1]
          }
        } else {
          const pOutBuff = res.data.pOutBuff
          if (pOutBuff === '证件信息失败') {
            this.$notify({
              title: '请将身份证放入正确位置',
              type: 'error',
              duration: 2500
            })
          } else {
            this.ybrySfzh = pOutBuff.split('|')[0]
          }
        }
        this.ybryQuery()
      }).catch(err => {
        this.fullscreenLoading = false
        console.log('err: {} ', err)
      })
    }
  }
}
</script>

<style scoped>

</style>
